package com.jrx.anytxn.investor.entity;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Optional;

/**
 *  
 * 表:tl_investor_loan_change 
 * @author mac 
 * @date 2020-06-08 
 */
public class TlInvestorLoanChange {
    /**
     * 主键
     * 表字段:id
     */
    private Long id;

    /**
     * 租戶id
     * 表字段:tenant_id
     */
    private String tenantId;

    /**
     * 机构号
     * 表字段:organization_id
     */
    private String organizationId;

    /**
     * 客户id
     * 表字段:customer_id
     */
    private String customerId;

    /**
     * 出资方贷款订单id
     * 表字段:investor_id
     */
    private String investorId;

    /**
     * 出资方贷款订单id
     * 表字段:investor_loan_id
     */
    private String investorLoanId;

    /**
     * 渠道id
     * 表字段:channel
     */
    private String channel;

    /**
     * 业务日期 yyyyMMdd
     * 表字段:business_date
     */
    private String businessDate;

    /**
     * 流水号
     * 表字段:seq_no
     */
    private String seqNo;

    /**
     * 事件码 T0 转正常 T1 转逾期 T2 转呆滞T3 转呆账 TN 转表外 TA 转表内
     * 表字段:event_code
     */
    private String eventCode;

    /**
     * 订单转移前状态 会计状态（0 = 正常 1 = 逾期 2 = 呆滞 3 = 呆账）非应计状态（A = 应计N = 非应计)
     * 表字段:before_status
     */
    private String beforeStatus;

    /**
     * 订单转移后状态 会计状态（0 = 正常 1 = 逾期 2 = 呆滞 3 = 呆账）非应计状态（A = 应计N = 非应计)
     * 表字段:after_status
     */
    private String afterStatus;

    /**
     * 本金发生额
     * 表字段:principal_amount
     */
    private BigDecimal principalAmount;

    /**
     * 利息发生额
     * 表字段:interest_amount
     */
    private BigDecimal interestAmount;

    /**
     * 罚息发生额
     * 表字段:penalty_interest_amount
     */
    private BigDecimal penaltyInterestAmount;

    /**
     * 复利发生额
     * 表字段:compound_interest_amount
     */
    private BigDecimal compoundInterestAmount;

    /**
     * 创建时间
     * 表字段:create_time
     */
    private Date createTime;

    /**
     * 获取主键
     * @return id Long
     */
    public Long getId() {
        return id;
    }

    /**
     * 设置主键
     * @param id 主键
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * 获取租戶id
     * @return tenantId String
     */
    public String getTenantId() {
        return tenantId;
    }

    /**
     * 设置租戶id
     * @param tenantId 租戶id
     */
    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    /**
     * 获取机构号
     * @return organizationId String
     */
    public String getOrganizationId() {
        return organizationId;
    }

    /**
     * 设置机构号
     * @param organizationId 机构号
     */
    public void setOrganizationId(String organizationId) {
        this.organizationId = organizationId;
    }

    /**
     * 获取客户id
     * @return customerId String
     */
    public String getCustomerId() {
        return customerId;
    }

    /**
     * 设置客户id
     * @param customerId 客户id
     */
    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    /**
     * 获取出资方贷款订单id
     * @return investorId String
     */
    public String getInvestorId() {
        return investorId;
    }

    /**
     * 设置出资方贷款订单id
     * @param investorId 出资方贷款订单id
     */
    public void setInvestorId(String investorId) {
        this.investorId = investorId;
    }

    /**
     * 获取出资方贷款订单id
     * @return investorLoanId String
     */
    public String getInvestorLoanId() {
        return investorLoanId;
    }

    /**
     * 设置出资方贷款订单id
     * @param investorLoanId 出资方贷款订单id
     */
    public void setInvestorLoanId(String investorLoanId) {
        this.investorLoanId = investorLoanId;
    }

    /**
     * 获取渠道id
     * @return channel String
     */
    public String getChannel() {
        return channel;
    }

    /**
     * 设置渠道id
     * @param channel 渠道id
     */
    public void setChannel(String channel) {
        this.channel = channel;
    }

    /**
     * 获取业务日期 yyyyMMdd
     * @return businessDate String
     */
    public String getBusinessDate() {
        return businessDate;
    }

    /**
     * 设置业务日期 yyyyMMdd
     * @param businessDate 业务日期 yyyyMMdd
     */
    public void setBusinessDate(String businessDate) {
        this.businessDate = businessDate;
    }

    /**
     * 获取流水号
     * @return seqNo String
     */
    public String getSeqNo() {
        return seqNo;
    }

    /**
     * 设置流水号
     * @param seqNo 流水号
     */
    public void setSeqNo(String seqNo) {
        this.seqNo = seqNo;
    }

    /**
     * 获取事件码 T0 转正常 T1 转逾期 T2 转呆滞T3 转呆账 TN 转表外 TA 转表内
     * @return eventCode String
     */
    public String getEventCode() {
        return eventCode;
    }

    /**
     * 设置事件码 T0 转正常 T1 转逾期 T2 转呆滞T3 转呆账 TN 转表外 TA 转表内
     * @param eventCode 事件码 T0 转正常 T1 转逾期 T2 转呆滞T3 转呆账 TN 转表外 TA 转表内
     */
    public void setEventCode(String eventCode) {
        this.eventCode = eventCode;
    }

    /**
     * 获取订单转移前状态 会计状态（0 = 正常 1 = 逾期 2 = 呆滞 3 = 呆账）非应计状态（A = 应计N = 非应计)
     * @return beforeStatus String
     */
    public String getBeforeStatus() {
        return beforeStatus;
    }

    /**
     * 设置订单转移前状态 会计状态（0 = 正常 1 = 逾期 2 = 呆滞 3 = 呆账）非应计状态（A = 应计N = 非应计)
     * @param beforeStatus 订单转移前状态 会计状态（0 = 正常 1 = 逾期 2 = 呆滞 3 = 呆账）非应计状态（A = 应计N = 非应计)
     */
    public void setBeforeStatus(String beforeStatus) {
        this.beforeStatus = beforeStatus;
    }

    /**
     * 获取订单转移后状态 会计状态（0 = 正常 1 = 逾期 2 = 呆滞 3 = 呆账）非应计状态（A = 应计N = 非应计)
     * @return afterStatus String
     */
    public String getAfterStatus() {
        return afterStatus;
    }

    /**
     * 设置订单转移后状态 会计状态（0 = 正常 1 = 逾期 2 = 呆滞 3 = 呆账）非应计状态（A = 应计N = 非应计)
     * @param afterStatus 订单转移后状态 会计状态（0 = 正常 1 = 逾期 2 = 呆滞 3 = 呆账）非应计状态（A = 应计N = 非应计)
     */
    public void setAfterStatus(String afterStatus) {
        this.afterStatus = afterStatus;
    }

    /**
     * 获取本金发生额
     * @return principalAmount BigDecimal
     */
    public BigDecimal getPrincipalAmount() {
        return principalAmount;
    }

    /**
     * 设置本金发生额
     * @param principalAmount 本金发生额
     */
    public void setPrincipalAmount(BigDecimal principalAmount) {
        this.principalAmount = principalAmount;
    }

    /**
     * 获取利息发生额
     * @return interestAmount BigDecimal
     */
    public BigDecimal getInterestAmount() {
        return interestAmount;
    }

    /**
     * 设置利息发生额
     * @param interestAmount 利息发生额
     */
    public void setInterestAmount(BigDecimal interestAmount) {
        this.interestAmount = interestAmount;
    }

    /**
     * 获取罚息发生额
     * @return penaltyInterestAmount BigDecimal
     */
    public BigDecimal getPenaltyInterestAmount() {
        return penaltyInterestAmount;
    }

    /**
     * 设置罚息发生额
     * @param penaltyInterestAmount 罚息发生额
     */
    public void setPenaltyInterestAmount(BigDecimal penaltyInterestAmount) {
        this.penaltyInterestAmount = penaltyInterestAmount;
    }

    /**
     * 获取复利发生额
     * @return compoundInterestAmount BigDecimal
     */
    public BigDecimal getCompoundInterestAmount() {
        return compoundInterestAmount;
    }

    /**
     * 设置复利发生额
     * @param compoundInterestAmount 复利发生额
     */
    public void setCompoundInterestAmount(BigDecimal compoundInterestAmount) {
        this.compoundInterestAmount = compoundInterestAmount;
    }

    /**
     * 获取创建时间
     * @return createTime Date
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * 设置创建时间
     * @param createTime 创建时间
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public TlInvestorLoanChange add(TlInvestorLoanChange loanChange){
        this.setEventCode(loanChange.getEventCode());
        this.setBeforeStatus(loanChange.getBeforeStatus());
        this.setAfterStatus(loanChange.getAfterStatus());
        this.setPrincipalAmount((Optional.ofNullable(this.getPrincipalAmount()).orElse(BigDecimal.ZERO)).add(Optional.ofNullable(loanChange.getPrincipalAmount()).orElse(BigDecimal.ZERO)));
        this.setInterestAmount((Optional.ofNullable(this.getInterestAmount()).orElse(BigDecimal.ZERO)).add(Optional.ofNullable(loanChange.getInterestAmount()).orElse(BigDecimal.ZERO)));
        this.setPenaltyInterestAmount((Optional.ofNullable(this.getPenaltyInterestAmount()).orElse(BigDecimal.ZERO)).add(Optional.ofNullable(loanChange.getPenaltyInterestAmount()).orElse(BigDecimal.ZERO)));
        this.setCompoundInterestAmount((Optional.ofNullable(this.getCompoundInterestAmount()).orElse(BigDecimal.ZERO)).add(Optional.ofNullable(loanChange.getCompoundInterestAmount()).orElse(BigDecimal.ZERO)));
        return this;
    }
}